package com.jr.util;


import java.util.List;

/**
 * 分页工具类
 *
 * @author 张闯
 * @since 1.0.0 2022-12-31
 */
public class PageHelper<T> {
    private String keyword;
    private String uid;
    private String eid;
    private String jid;

    private Integer nowpage;
    private Integer indexpage = 0;
    private Integer showcount = 10;
    private Integer countnums;
    private Integer countpage;
    private List<T> userJobEnterpriseDaoList;

    public String getJid() {
        return jid;
    }

    public void setJid(String jid) {
        this.jid = jid;
    }


    public String getKeyword() {
        return keyword;
    }

    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public String getEid() {
        return eid;
    }

    public void setEid(String eid) {
        this.eid = eid;
    }


    public Integer getNowpage() {
        return nowpage;
    }

    public void setNowpage(Integer nowpage) {
        this.nowpage = nowpage;
    }

    public Integer getIndexpage() {
        if (!(nowpage == null && countnums == null && countpage == null)) {
            if (nowpage > 0) {
                indexpage = (nowpage - 1) * 10;
            }
            return indexpage;
        } else {
            return 0;
        }

    }

    public void setIndexpage(Integer indexpage) {
        this.indexpage = indexpage;
    }

    public Integer getShowcount() {
        return showcount;
    }

    public void setShowcount(Integer showcount) {
        this.showcount = showcount;
    }

    public Integer getCountnums() {
        return countnums;
    }

    public void setCountnums(Integer countnums) {
        this.countnums = countnums;
    }

    public Integer getCountpage() {
        return countpage;
    }

    public void setCountpage() {
        this.countpage = this.countnums % this.showcount == 0 ?
                (this.countnums / this.showcount) :
                (this.countnums / this.showcount) + 1;
    }


    public List<T> getUserJobEnterpriseDaoList() {
        return userJobEnterpriseDaoList;
    }

    public void setUserJobEnterpriseDaoList(List<T> userJobEnterpriseDaoList) {
        this.userJobEnterpriseDaoList = userJobEnterpriseDaoList;
    }

    public PageHelper pageHelperValue() {
        return new PageHelper();
    }

    @Override
    public String toString() {
        return "PageHelper{" + "\n" +
                "keyword='" + keyword + '\'' + "\n" +
                ", uid='" + uid + '\'' + "\n" +
                ", eid='" + eid + '\'' + "\n" +
                ", nowpage=" + nowpage + "\n" +
                ", indexpage=" + indexpage + "\n" +
                ", showcount=" + showcount + "\n" +
                ", countnums=" + countnums + "\n" +
                ", countpage=" + countpage + "\n" +
                ", userJobEnterpriseDaoList=" + userJobEnterpriseDaoList + "\n" +
                '}';
    }
}
